package com.ylw.uibasic;

import android.os.Bundle;
import android.app.Activity;
import android.content.Intent;
import android.view.Menu;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;

public class AnotherActivity extends Activity {
	
	private Button doneButton;
	private EditText enterEditText;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_another);
		
		doneButton = (Button)this.findViewById(R.id.done_button);
		this.enterEditText = (EditText)this.findViewById(R.id.enterEditText);
		
		this.doneButton.setOnClickListener(new View.OnClickListener() {
			
			@Override
			public void onClick(View arg0) {
				// Get data from edit field and return it 
				Intent data = new Intent();
				data.putExtra("com.ylw.uibasic.message", enterEditText.getText().toString());
				setResult(Activity.RESULT_OK, data);
				finish();
			}
		});
	}

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		// Inflate the menu; this adds items to the action bar if it is present.
		getMenuInflater().inflate(R.menu.another, menu);
		return true;
	}

}
